export enum ExternalApps {
  LogsAudit = 'logsAudit',
  EShield = 'eshield',
  CloudAudit = 'cloudAudit',
}

export enum InternalApps {
  Main = 'main',
  Template = 'template',
  UserManagement = 'userManagement',
  Firewall = 'firewall',
}

export enum InternalServices {
  ProxyService = 'proxy',
}

interface AppConfig {
  /**
   * 若未指定，则默认为 lts/gallium
   */
  nodeVersion?: string,
}

export default class Modules {
  static appConfigs: Record<string, AppConfig> = {
    [ExternalApps.LogsAudit]: {},
    [ExternalApps.EShield]: { nodeVersion: '10.24.1' },
    [ExternalApps.CloudAudit]: {},
  };

  static getAppConfig = (name: string): AppConfig => {
    return Modules.appConfigs[name] || {};
  };

  static isExternal = (name: string) => {
    return Modules.isExternalApp(name);
  };

  static isExternalApp = (name: string) => {
    return Object.values<string>(ExternalApps).includes(name);
  };

  static isInternal = (name: string) => {
    return Modules.isInternalApp(name) || Modules.isInternalService(name);
  };

  static isInternalApp = (name: string) => {
    return Object.values<string>(InternalApps).includes(name);
  };

  static isInternalService = (name: string) => {
    return Object.values<string>(InternalServices).includes(name);
  };
}
